import { useUserStore } from "../store/user"

export default function hasParm(value: any) {
    const userStore = useUserStore()
    // 当前用户拥有的权限字段
    const permissions = userStore.getPermissionCodeList

    if (value && value instanceof Array && value.length > 0) {
        // 资源所需的权限字段
        const permissionRoles = value
        // 判断是否存在资源所需的权限字符串
        const hasPermission = permissions.some((role) => {
            return permissionRoles.includes(role)
        })
        return hasPermission
    } else {
        throw new Error(`v-if="global.$hasPerm("['add', 'edit']")`)
    }

}